(defun my-python-mode-common-hook()
  (setq hs-minor-mode t)
  (setq tab-width 2 indent-tabs-mode nil)
  (setq abbrev-mode t)
  (local-set-key (kbd "RET") 'newline-and-indent)
  (local-set-key (kbd "<return>") 'newline-and-indent)
  )
(add-hook 'python-mode-hook 'my-python-mode-common-hook)

(when (load "flymake" t)
  (defun flymake-pyflakes-init ()
      (let* ((temp-file (flymake-init-create-temp-buffer-copy
                         'flymake-create-temp-inplace))
             (local-file (file-relative-name
                          temp-file
                          (file-name-directory buffer-file-name))))
        (list "pyflakes" (list local-file))))
  (add-to-list 'flymake-allowed-file-name-masks
               '("\\.py\\'" flymake-pyflakes-init)))

;; (add-hook 'find-file-hook 'flymake-find-file-hook)
(load-library "flymake-cursor")  ;show flymake error message in minibuffer
;; (global-set-key (kbd "<f11>") 'flymake-start-syntax-check)
;; (global-set-key (kbd "<s-up>") 'flymake-goto-prev-error)
;; (global-set-key (kbd "<s-down>") 'flymake-goto-next-error)

(custom-set-faces
     '(flymake-errline ((((class color)) (:underline "red"))))
     '(flymake-warnline ((((class color)) (:underline "yellow1")))))
(setq flymake-no-changes-timeout 600)
